with open('input.txt') as file:
    numbers = list(map(int, file.read().split(',')))

def make_finsh_count():
    memory = {}
    def finsh_count(init_day: int, total_day: int):
        if init_day >= total_day:
            return 1
        
        res = memory.get((init_day, total_day))
        if res is not None:
            return res

        born_count = (total_day - init_day - 1) // 7 + 1

        day = total_day - init_day - 1
        baby_sum = finsh_count(8, day)

        for c in range(1, born_count):
            day -= 7
            baby_sum += finsh_count(8, day)

        memory[(init_day, total_day)] = baby_sum + 1
        return baby_sum + 1

    return finsh_count

finsh_count = make_finsh_count()

result = 0
for number in numbers:
    result += finsh_count(number, 256)

print(result)